package net.obxlabs.tweetpad.behaviour;

import net.nexttext.*;
import net.nexttext.behaviour.*;
import net.nexttext.property.BooleanProperty;

public class Key extends AbstractAction {
	private String key;
	public Key(String propName) {
		key = propName;
	}
	
	public ActionResult behave(TextObject to) {
		BooleanProperty toKey = (BooleanProperty)to.getProperty(key);
		if (toKey != null) {
			// set it
			toKey.set(true);
		} else {
			// create it
			to.init(key, new BooleanProperty(true));
		}
		
		return new ActionResult(true, true, false);
	}
}
